package com.sky.controller.employee;

import com.sky.constant.MeetingRoomMaintainConstant;
import com.sky.dto.MeetingRoomMaintainPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.MeetingRoomMaintainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/employee/maintainMeetingRoom")
@Slf4j
@CrossOrigin
@Builder
@Api(tags = "会议室维护")
public class MeetingRoomMaintainController {
    @Autowired
    private MeetingRoomMaintainService meetingRoomMaintainService;

    // 查询所有会议室
    @ApiOperation(value="分页查询会议室信息")
    @GetMapping("/page")
    public Result<PageResult> page(MeetingRoomMaintainPageQueryDTO meetingRoomMaintainPageQueryDTO){
        log.info("分页查询: {}", meetingRoomMaintainPageQueryDTO); //框架会自动将数据封装到实体类对象中，即使有一些为空
        PageResult pageResult = meetingRoomMaintainService.pageQuery(meetingRoomMaintainPageQueryDTO);
        return Result.success(pageResult);
    }

    // 呼叫清洁工打扫会议室
    @ApiOperation(value="呼叫清洁工打扫会议室")
    @GetMapping("/callCleaner/{id}")
    public Result callCleaner(@PathVariable Long id){
        if (meetingRoomMaintainService.callCleaner(id)) {
            return Result.success(MeetingRoomMaintainConstant.CallCleanerSuccess);
        } else {
            return Result.error(MeetingRoomMaintainConstant.CallCleanerError);
        }
    }

    // 呼叫维修工修理会议室
    @ApiOperation(value="呼叫维修工修理会议室")
    @GetMapping("/callRepairman/{id}")
    public Result callRepairman(@PathVariable Long id){
        if (meetingRoomMaintainService.callRepairman(id)) {
            return Result.success(MeetingRoomMaintainConstant.CallRepairmanSuccess);
        } else {
            return Result.error(MeetingRoomMaintainConstant.CallRepairmanError);
        }
    }

}
